# 切片
# L = [1, 2, 3, 4, 5, 6, 7, 8, 9]
# print(L[0], L[1], L[2])
# i = 0
# while i < 3:
#     print(L[i])
#     i += 1

L = [1, 2, 3, 4, 5, 6, 7, 8, 9]
print(L[0:3])  # [1, 2, 3]
print(L[1:5])  # [2, 3, 4, 5]
print(L[-5:-1])  # [5, 6, 7, 8]
print(L[3:])  # [4, 5, 6, 7, 8, 9]
print(L[:5:2])  # [1, 3, 5]
print(L[::2])  # [1, 3, 5, 7, 9]

# 可切片的对象有：字符串、列表、元组
# 不可切片的对象有：集合、字典
# str = "123456"
str = (1, 2, 3, 4, 5)
print(str[0:3])
